<layout name="page" />
<block name="content">
	{:widget('page_header/simple',array('name'=>'业务权限管理','search'=>'N'))}
	<div class="operate-panel">
		<i class="mid"></i>
		<a class="btn btn-normal" onclick="add()">新增</a>
		<a class="btn btn-normal" onclick="save()">保存</a>
		<i class="split"></i>
		<a class="btn btn-del" onclick="del()">删除</a>
	</div>
	<div class="x1 sub box">
		<div class="w30 m100" style="margin-bottom: 20px;">
			<div class="table">
				<ul>
					<li class="thead" >
						<span class="w15" >名称</span>
						<span class="x1">状态</span>
					</li>
					<foreach name="list" val="data">
						<li class="tbody" data="{$data.id}">
							<span class="w15 ">{$data.name}</span>
							<span class="x1">{:status($data['is_del'])}</span>
						</li>
					</foreach>
				</ul>
			</div>
		</div>
		<div style="width:16px;"></div>
		<div class="x1 frame m100" style="height:320px;">
			<form id="form_data" name="form_data"method="post" action="" >
				<input type="hidden" name="id" id="id">
				<input type="hidden" name="ajax" id="ajax" value="1">
				<input type="hidden" name="opmode" id="opmode" value="">
				<div class="box">
					<label class="input-label" for="name">名称*：</label>
					<input class="input w19" type="text" id="name" name="name"  check="required" info="请输入名称">
				</div>
				<div class="box">
					<label class="input-label" for="sort">排序：</label>
					<input class="input w10"  type="text" id="sort" name="sort" >
				</div>
				<div class="box">
					<label class="input-label" for="is_del">状态：</label>
					<select  class="select w10" name="is_del" id="is_del">
						<option  value="0">启用</option>
						<option value="1">禁用</option>
					</select>
					<i class="icon"></i>
				</div>
				<div class="box">
					<label class="input-label" for="remark">备注：</label>
					<textarea id="remark" class="textarea" name="remark" rows="" cols=""></textarea>
				</div>
			</form>
		</div>
	</div>
</block>
<block name="js">
	<script type="text/javascript">
		layui.use(['global'], function() {
			set_return_url(null);
			var fn = {
				add : function() {
					winopen("{:url('add')}", 560, 470);
				},
				save : function() {
					send_form("form_data", "{:url('save')}", "{:url('index')}", function(ret) {
						if (ret.status) {
							layer.msg(ret.info, {
								time : 1200
							}, function() {
								location.reload(true);
							});
						}
					});
				},
				del : function() {
					if ($(".table li.active").length == 0) {
						layer.msg('请选择要删除的职位');
						return false;
					}
					//信息框-例2
					layer.msg('确定要删除吗?', {
						time : 0,
						btn : ['确定', '取消'],
						yes : function(index) {
							var vars = $("#form_data").serialize();
							send_ajax("{:url('del')}", vars, function(ret) {
								if (ret.status) {
									layer.msg(ret.info, {
										time : 1200
									}, function() {
										location.reload(true);
									});
								}
							});
						},
						no : function(index) {
							layer.close(index);
						}
					});
				}
			};

			win_exp(fn);

			$(".table li.tbody").click(function() {
				$(".table li.active").removeClass("active");
				$this = $(this);
				$this.addClass("active");
				vars = {};
				vars.id = $this.attr('data');
				send_ajax("{:url('read')}", vars, function(data) {
					show_data(data);
				});
				return false;
			});

			function show_data(result) {
				for (var s in result.data) {
					set_val(s, result.data[s]);
				}
				$("#opmode").val("edit");
			};
		});
	</script>
</block>